﻿#ifndef SEARCHTAB_H
#define SEARCHTAB_H

#include <QWidget>
#include <QStandardItemModel>
#include "Model/Base/PagedResultDto.h"
#include "Model/Dto/DevArvSearchResponse.h"
#include "Base/Command.h"
namespace Ui {
class SearchTab;
}

class SearchTab : public QWidget
{
    Q_OBJECT

public:
    explicit SearchTab(QWidget *parent = nullptr);
    ~SearchTab();

    void loadSearchTableHeader();
    void loadCmdTableHeader();
signals:
    void sig_sendSearchPost(QVariantMap params);
    void sig_addCmdFromPad(QList<SearchCmdModel>);
private slots:
    void on_btn_lend_clicked();

    void on_btn_return_clicked();

    void on_btn_search_clicked();
    void slot_SearchInfoReceived(PagedResultDto<DevArvData>);
    void on_btn_prepage_clicked();

    void on_btn_nextpage_clicked();

    void on_btn_lendadd_clicked();

    void on_btn_returnadd_clicked();

    void on_btn_cmddelete_clicked();

    void on_btn_cmdclear_clicked();

    void on_btn_confirm_clicked();

private:
    Ui::SearchTab *ui;
    QStandardItemModel mSearchModel;    //查询table的model
    QStandardItemModel mCmdModel;    //添加业务指令table的model

    vector<DevArvData> mSearchResult;
    QList<SearchCmdModel> mSearchCmdList;

    int selectRow;  //记录发起业务时，选中的行
    QMap<int,QString> mSearchKeyMap;
    int totalPages=0;   //搜索结果总页数
    int currentPage = 0;    //当前页
    QString lastSearchText; //上一次搜索内容
    int lastKeyWord;    //上一次搜索关键字
};

#endif // SEARCHTAB_H
